#ifndef __SR04_H
#define __SR04_H

#include "sys.h"
#include "delay.h"
#include "FreeRTOS.h"
#include "queue.h"

#define SR04_Trig_GPIO GPIOA
#define SR04_Trig_PIN GPIO_PIN_1
#define SR04_Trig_SCLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()

#define SR04_Echo_GPIO GPIOA
#define SR04_Echo_PIN GPIO_PIN_0
#define SR04_Echo_SCLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()

#define SR04_Trig(x) do{x ? HAL_GPIO_WritePin(SR04_Trig_GPIO, SR04_Trig_PIN, GPIO_PIN_SET) : \
                       HAL_GPIO_WritePin(SR04_Trig_GPIO, SR04_Trig_PIN, GPIO_PIN_RESET);} while(0)

#define SR04_Echo_Read() HAL_GPIO_ReadPin(SR04_Echo_GPIO, SR04_Echo_PIN)

void SR04_GPIO_Config(void);
float SR04_distance(void);

#endif
